package com.lufei.dh.bottom.Bean;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.LinearSnapHelper;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.lufei.dh.R;
import com.lufei.dh.bottom.Adapter.Adapter_hor;

import java.util.ArrayList;
import java.util.List;

import me.drakeet.multitype.ItemViewBinder;

/**
 * 版权：易金卡沃 版权所有
 * <p>
 * 作者：lufei
 * <p>
 * 创建日期：2018/7/10
 * <p>
 * 描述：
 * <p>
 * 修订历史：
 */
public class Horizontal_ItemViewBinder extends ItemViewBinder<Horizontal_Item, Horizontal_ItemViewBinder.ViewHolder> {
    public static Context mContext;

    public Horizontal_ItemViewBinder(Context mContext) {
        this.mContext = mContext;
    }

    @NonNull
    @Override
    protected ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        View root = inflater.inflate(R.layout.item_horizontal, parent, false);
        return new ViewHolder(root);
    }

    @Override
    protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull Horizontal_Item horizontal_Item) {
//        Glide.with(this).load(url).bitmapTransform(new GlideCircleTransform(this)).crossFade(1000).into(image2);
//不带白色边框的圆形图片加载
//        Glide.with(mContext).load("").centerCrop().placeholder(R.drawable.ic_launcher)
//                .transform(new GlideCircleTransform(mContext))
//                .diskCacheStrategy(DiskCacheStrategy.SOURCE).into(holder.imageView);
//        holder.textView.setText(horizontal_Item.getTime());
    }

    static class ViewHolder extends RecyclerView.ViewHolder {

        private RecyclerView recyclerView;
        private Adapter_hor adapter;

        List<Horizontal_Item> list = new ArrayList<>();

        private ViewHolder(@NonNull View itemView) {
            super(itemView);

            int size=7;
            for (int i = 0; i < size; i++) {
                list.add(new Horizontal_Item("周"+i,1));
            }

            recyclerView = itemView.findViewById(R.id.id_hor_recyclerview);
            LinearLayoutManager layoutManager = new LinearLayoutManager(itemView.getContext());
            layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
            recyclerView.setLayoutManager(layoutManager);
            new LinearSnapHelper().attachToRecyclerView(recyclerView);
            adapter = new Adapter_hor(list, mContext);
            recyclerView.setAdapter(adapter);
        }


//        private void setPosts(List<Post> posts) {
//            adapter.setPosts(posts);
//            adapter.notifyDataSetChanged();
//        }
    }
}
